﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL_Class;

namespace NLLSite.Administrator.UserControl
{
    public partial class AddNewCourse : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void Reset()
        {
            txtTenKhoaHoc.Text = string.Empty;
            txtThumbImage.Text = string.Empty;
            txtDescription.Text = string.Empty;
            CKEditor1.Text = string.Empty;
            txtSoLuong.Text = string.Empty;
            txtLichHoc.Text = string.Empty;
            txtGioHoc.Text = string.Empty;
            dpkBeginDate.SelectedValue = string.Empty;
            CheckBox1.Checked = false;
            CheckBox2.Checked = false;
        }

        protected void btnThem_Click(object sender, EventArgs e)
        {
            KhoaHoc c = new KhoaHoc();
            Course cou = new Course();

            cou.Name = txtTenKhoaHoc.Text;
            cou.ThumbImage = txtThumbImage.Text;
            cou.Description = txtDescription.Text;
            cou.Content = CKEditor1.Text;
            cou.Quantities = Int32.Parse(txtSoLuong.Text);
            cou.StartDate = dpkBeginDate.SelectedDate;
            cou.Schedule = txtLichHoc.Text;
            cou.TimeSlot = txtGioHoc.Text;
            cou.IsFrontPage = CheckBox1.Checked;
            cou.Status = CheckBox2.Checked;

            Label1.Text = c.AddNewCourse(cou);
            Reset();
            Response.Redirect("QuanLyKhoaHoc.aspx");
        }
    }
}